package com.zqwh.xtool.model.offline;

import android.content.Context;

import com.zqwh.yj.sdk.utils.httpRequest.subscribers.NetCallback;
import com.zqwh.xtool.api.offline.StockResposity;
import com.zqwh.xtool.converter.Stock2StockVOConverter;
import com.zqwh.xtool.domain.LendItem;
import com.zqwh.xtool.domain.StockVO;
import com.zqwh.xtool.greendao.db.Stock;
import com.zqwh.xtool.model.StockModel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class StockModelOfflineImpl implements StockModel {
    private Context context;
    private StockResposity stockResposity;

    public StockModelOfflineImpl(Context context) {
        this.context = context;
        this.stockResposity = new StockResposity(this.context);
    }

    @Override
    public void getStock(Long devId, Boolean hasRFID, Boolean hasLent, NetCallback<List<LendItem>> callback) {

    }

    @Override
    public void initStock(Long devId, String epcs, String toolIds, NetCallback<Object> callback) {

    }

    @Override
    public void getStockListByDevId(Long devId, NetCallback<HashMap<String, ArrayList<StockVO>>> callback) {
        List<Stock> rfidStockList = stockResposity.queryStockList(devId,false, true);
        List<Stock> notRfidStockList = stockResposity.queryStockList(devId, false, false);
        HashMap<String, ArrayList<StockVO>> resultMap = new HashMap<>();
        ArrayList rfidStockArrayList = new ArrayList(rfidStockList);
        resultMap.put("rfid_stock", Stock2StockVOConverter.convert(rfidStockArrayList));
        ArrayList noRfidStockArrayList = new ArrayList(notRfidStockList);
        resultMap.put("no_rfid_stock", Stock2StockVOConverter.convert(noRfidStockArrayList));
        callback.onSuccess(resultMap);
    }

    @Override
    public void getLentStockList(Long devId, String epcs, String toolIds, NetCallback<ArrayList<StockVO>> callback) {

    }

    @Override
    public void getNoRfidStockListByDevId(Long devId, NetCallback<ArrayList<StockVO>> callback) {

    }

    @Override
    public void incStock(Long devId, String incEpcs, String incToolIds, NetCallback<Object> callback) {

    }

    @Override
    public void redStock(Long devId, String stockIds, NetCallback<Object> callback) {

    }


    @Override
    public void updateEpcPosition(Long devId, List<String> positions, NetCallback<Object> callback) {

    }

    @Override
    public boolean insertMultStock(List<Stock> stockList) {
        return stockResposity.insertMultStock(stockList);
    }
}
